package com.example.springboot.controller;

import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @Description: LoginController
 * @Author wenlinyu
 * @Date: 2020/12/17 15:15
 * @Version 1.0
 */
@RestController
public class LoginController {

    /**
     * spring-session存储到redis中
     * @param username
     * @param password
     * @param session
     * @return
     */
    @RequestMapping("/login")
    public String login(String username, String password, HttpSession session) {
        if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
            session.setAttribute("loginUser", username);
            return "success";
        }
        return "failed";
    }
}
